#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int x = 0;
	int n = 0;
	scanf("%d%d", &x, &n);
	int sum = x + n - 1;
	int week = sum / 7;
	int ret = sum % 7;
	if (ret == 6)ret = 5;
	if (x == 6)x = 6;
	if (x == 7)x = 6;
	x--;
	long hour = (long)week * 5 * 250 + ret * 250 - x * 250;
	printf("%ld", hour);
	return 0;
}